package com.scorpionstudio.girlstoryshop;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.scorpionstudio.girlstoryshop.adapter.MainAdapter;
import com.scorpionstudio.girlstoryshop.bean.ItemGridMain;
import com.scorpionstudio.girlstoryshop.utils.Variable;


public class MainSaleActivity extends ScorpionActivity implements OnItemClickListener {
	private GridView mGridMain;
	private ArrayList<String> mListName = new ArrayList<String>();
	private ArrayList<Integer> mListImgLink = new ArrayList<Integer>();
	private ArrayList<ItemGridMain> mArrayList = new ArrayList<ItemGridMain>();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_sale);
		mGridMain = (GridView) findViewById(R.id.grd_main);
		mListName.add("Mỹ Phẩm");
		mListName.add("Thẩm Mỹ");
		mListName.add("Mũ");
		mListName.add("Quần Áo");
		mListName.add("Khăn / Tất");
		mListName.add("Giầy / Dép");
		mListName.add("Phụ kiện");
		mListName.add("Túi");
		mListName.add("Váy");
		mListName.add("Áo ngủ");
		mListName.add("Gia Đình");
		mListName.add("Hàng Hót");
		
		// Img
		mListImgLink.add(R.drawable.icon_mypham);
		mListImgLink.add(R.drawable.icon_thammy);
		mListImgLink.add(R.drawable.icon_mu);
		mListImgLink.add(R.drawable.icon_vay);
		mListImgLink.add(R.drawable.icon_tat);
		mListImgLink.add(R.drawable.icon_giay);
		mListImgLink.add(R.drawable.icon_phukien);
		mListImgLink.add(R.drawable.icon_tui);
		mListImgLink.add(R.drawable.icon_vi);
		mListImgLink.add(R.drawable.icon_aongu);
		mListImgLink.add(R.drawable.icon_giadinh);
		mListImgLink.add(R.drawable.icon_hot);
		for (int i = 0 ;i < mListName.size(); i++){
            ItemGridMain mItemGrid = new ItemGridMain();
			mItemGrid.setImgName(mListName.get(i));
            mItemGrid.setIconId(mListImgLink.get(i));
			mArrayList.add(mItemGrid);
		}
		
		MainAdapter mainAdapter = new MainAdapter(MainSaleActivity.this, android.R.layout.simple_list_item_1, mArrayList);
		mGridMain.setAdapter(mainAdapter);
		mGridMain.setOnItemClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main_sale, menu);
		return true;
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		Intent mDetai = new Intent(MainSaleActivity.this,DetailMenuTwoColumnActivity.class);
		mDetai.putExtra(Variable.MENU_INDEX, position);
		startActivity(mDetai);
		finish();
	}

}
